
		<div class="ui-portlet">
			{{template wxes/_user_wxes}}
			<ol class="breadcrumb">
			  <li><a href="/users/index"><i class="fa fa-home"></i>&nbsp;&nbsp;135公众平台</a></li>
			  <li class="active">参数配置</li>
			  {{if $current_wxinfo}}
			  	<li>公众号：{{$current_wxinfo['Wx']['name']}}</li>
			  {{/if}}
			</ol>
		</div>       
       <hr>
       
       <style>
		.radios input[type="radio"]{margin-left:20px;}
		</style>
		
		<br/>
       <p class="text-right">
       	<a href="{{$this->Html->url('/wx_variables/setting')}}">普通参数设置</a> &nbsp;&nbsp;
       	<a href="{{$this->Html->url('/wx_variables/setting?type=dev')}}">开发者配置</a> &nbsp;&nbsp;
       	<!-- <a href="{{$this->Html->url('/wx_variables/setting?type=preview')}}">预览设置</a> -->
       </p>
<?php $i=0;?>
{{$this->Form->create('WxVariable',array('class'=>'form-horizontal','role'=>'form'))}}

	<input type="hidden" name="manage_wxid" value="{{$manage_wxid}}">
	{{if $current_wxinfo && $_GET['type'] == 'preview'}}
	
		<div class="ui-portlet-header">
	      <span class="title">图文预览设置</span>            
		</div>
		<?php $i++;?> 
		<div class="form-group">
			<label class="col-sm-3 control-label" for="WxMenuName">预览微信号</label>
			<div class="col-sm-9 controls">
				<span>{{$values['preview_wechats']['value']}}</span>
			</div>
		</div>
		{{if $errmsg}}
			<p class="alert alert-warning">{{$errmsg}}</p>
		{{else}}
			<img src="https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket={{$ticket}}">
			<p>扫描二维码后，扫描的微信号直接设为预览微信号，可设置多个预览账号</p>
		{{/if}}
	
	{{elseif $current_wxinfo && $_GET['type'] == 'dev'}}	
		<br>
       <div class="ui-portlet-header">
	      <span class="title">开发者配置</span>            
		</div>
		
		<div class="alert alert-warning">提示：公众号授权可管理公众号素材，菜单与自定义回复需要进行开发者配置。</div>
       
		<?php $i++;?>
		<div class="form-group">
			<label class="col-sm-3 control-label" for="WxMenuName">AppID(应用ID)</label>
			<div class="col-sm-9 controls">
				{{$this->Form->hidden($i.'.id',array('value'=>$ids['wxAppId']))}}
				{{$this->Form->hidden($i.'.name',array('value'=>'wxAppId'))}}
				{{$this->Form->input($i.'.value',array('type'=>'text','class'=>'form-control','div'=>false,'label'=>false,'value'=>$values['wxAppId']['value']))}}
				<p><small>"AppID(应用ID)"可到微信开发者中心查看</small></p>
			</div>
		</div>
		<?php $i++;?>
		<div class="form-group">
			<label class="col-sm-3 control-label" for="WxMenuName">AppSecret(应用密钥)</label>
			<div class="col-sm-9 controls">
				{{$this->Form->hidden($i.'.id',array('value'=>$ids['wxAppSecret']))}}
				{{$this->Form->hidden($i.'.name',array('value'=>'wxAppSecret'))}}
				{{$this->Form->input($i.'.value',array('type'=>'text','class'=>'form-control','div'=>false,'label'=>false,'value'=>$values['wxAppSecret']['value']))}}
				<p><small>"AppSecret(应用密钥)"可到微信开发者中心查看</small></p>
			</div>
		</div>
		
		<div class="form-group">
			<label class="col-sm-3 control-label" for="WxMenuName">URL(服务器地址)</label>
			<div class="col-sm-9 controls">
				<p style="line-height:50px;">http://www.135editor.com/weixin/msg/{{$current_wxinfo['Wx']['id']}}</p>
			</div>
		</div>
		
		<?php $i++;?>
		<div class="form-group">
			<label class="col-sm-3 control-label" for="WxMenuName">微信Token</label>
			<div class="col-sm-9 controls">
				{{$this->Form->hidden($i.'.id',array('value'=>$ids['token']))}}
				{{$this->Form->hidden($i.'.name',array('value'=>'token'))}}
				{{$this->Form->input($i.'.value',array('type'=>'text','id'=>'WxToken','style'=>'width:400px;display:inline-block;','class'=>'form-control','div'=>false,'label'=>false,'value'=>$values['token']['value']))}}
				<button type="button" class="btn btn-primary btn-sm" onclick="$('#WxToken').val(randomString(32));">随机生成</button>
				<p><small>安全令牌长度为3-32字符,与微信开发者配置中填的Token一致</small></p>
			</div>
		</div>
		<?php $i++;?>
		<div class="form-group">
			<label class="col-sm-3 control-label" for="WxMenuName">EncodingAESKey</label>
			<div class="col-sm-9 controls">
				{{$this->Form->hidden($i.'.id',array('value'=>$ids['wxAESKey']))}}
				{{$this->Form->hidden($i.'.name',array('value'=>'wxAESKey'))}}
				{{$this->Form->input($i.'.value',array('type'=>'text','id'=>'WxAESKey','style'=>'width:450px;display:inline-block;','class'=>'form-control','div'=>false,'label'=>false,'value'=>$values['wxAESKey']['value']))}}
				<button type="button" class="btn btn-primary btn-sm" onclick="$('#WxAESKey').val(randomString(43));">随机生成</button>
				<p><small>消息加密密钥由43位字符组成，与微信开发者配置中填的EncodingAESKey一致</small></p>
			</div>
		</div>
	{{else}}
		<div class="ui-portlet-header">
	      <span class="title">水印图片配置</span> 
		</div> 
		<div class="alert alert-info">
			<p><strong>重要提示：</strong></p>
			<p>水印图片请使用透明png，尺寸不会缩放，按原水印图片尺寸作为水印</p>
			<p>设置水印位置后，水印才会生效</p>
			<p>同时设置了图片与文字时，仅图文水印生效。</p>
		</div>
		<?php $i++;?> 
		<div class="form-group">
			<label class="col-sm-3 control-label" for="WxMenuName">水印图片</label>
			<div class="col-sm-9 controls">
		      {{$this->Form->hidden($i.'.id',array('value'=>$ids['watermark']))}}
				{{$this->Form->hidden($i.'.name',array('value'=>'watermark'))}}
				{{$this->MForm->swfupload('WxVariable.'.$i.'.value',
					array('type'=>'text',
						'class'=>'form-control',
						'div'=>false,'label'=>false,
						'file_types'=>'*.png',
						//'no_db' => 1,
						'upload_limit'=>1,'isadmin' => false,
						'value'=>$values['watermark']['value']
					))}}
				<p style="color:red;">请使用透明png图片作为水印图片</p>
			</div>
		</div>
		<?php $i++;?> 
		<div class="form-group">
			<label class="col-sm-3 control-label" for="WxMenuName">水印文字</label>
			<div class="col-sm-9 controls">
		      {{$this->Form->hidden($i.'.id',array('value'=>$ids['watermark_text']))}}
				{{$this->Form->hidden($i.'.name',array('value'=>'watermark_text'))}}
				{{$this->Form->input('WxVariable.'.$i.'.value',
					array('type'=>'text',
						'class'=>'form-control',
						'div'=>false,'label'=>false,'after'=>'<p>水印图片优先生效。如要取消水印图片使用文字水印，删除水印图片输入框中的网址提交保存即可。</p>',
						'value'=>$values['watermark_text']['value']
					))}}
			</div>
		</div>
		<?php $i++;?>
		<div class="form-group">
			<label class="col-sm-3 control-label" for="WxMenuName">水印默认位置</label>
			<div class="col-sm-9 controls">
		      {{$this->Form->hidden($i.'.id',array('value'=>$ids['watermark_pos']))}}
				{{$this->Form->hidden($i.'.name',array('value'=>'watermark_pos'))}}
				{{$this->Form->input($i.'.value',array(
					'type'=>'radio','class'=>'','legend'=>'',
					'div'=>'radios','label'=>false,
					'value'=>$values['watermark_pos']['value'],
					'options' => array('0'=> '无水印<br>','1'=> '顶部上','2'=>'顶部中','3'=>'顶部右<br>','4'=>'中部左','5'=>'中部中','6'=>'中部右<br>','7'=>'底部左','8'=>'底部中','9'=>'底部右'),
					'after'=>'<p><br/>设置水印位置后，上传图片会自动加水印</p>',
				))}}
			</div>
		</div>
		
		<div class="form-group">
			<label class="col-sm-3 control-label" for="WxMenuName">消息转发至客服</label>
			<div class="col-sm-9 controls">
				{{$this->Form->hidden($i.'.id',array('value'=>$ids['wxTrKf']))}}
				{{$this->Form->hidden($i.'.name',array('value'=>'wxTrKf'))}}
				{{$this->Form->input($i.'.value',array('type'=>'text','class'=>'form-control','div'=>false,'label'=>false,'value'=>$values['wxTrKf']['value']))}}
				<p><small>开启微信客服后，未命中自动回复的消息，转发至客服</small></p>
			</div>
		</div>
		
	{{/if}}
	
	{{if $_GET['type'] != 'preview'}}
	
	<div class="form-group">
		<label class="col-sm-3 control-label"></label>
		<div class="col-sm-9"><input class="btn btn-primary" type="submit" value="提交"></div>
	</div>
	{{/if}}
	
{{$this->Form->end()}}
		
		
			
		<div class="ui-portlet-header">
	      <span class="title">已授权公众号</span>            
		</div>
		<table class="table">
			<thead><tr><td>公众号</td><td>授权时间</td><td>权限刷新时间</td><td>状态</td></tr></thead>
       <portlet title="已授权公众号" portlet="body" model="Oauthbind" info="conditions[user_id]=$current_user_id&conditions[source]=wechatComp" list_tpl="inner">
       		<!-- <a href="{{$this->Html->url('http://www.135plat.com/wxes/pinfo/'.$item['id'])}}" class="btn btn-lg btn-success"> {{$item['oauth_name']}} </a> &nbsp;
       		 -->
       		<tr><td>{{$item['oauth_name']}}</td><td>{{date('Y-m-d H:i',$item['created'])}}</td><td>{{date('Y-m-d H:i',$item['updated'])}}</td><td>{{if time() - $item['updated'] > 7200}} 已过期 {{/if}}</td></tr>
       </portlet>
       
       </table>
       <p>
	        <a target="_blank" href="http://www.135plat.com/books/chapter/2/28"> 取消已授权绑定公众号的方法</a>
		</p>
			
<script>
$(function(){
	$('#WxMenuType').change(function(){
		if($(this).val()=='view'){
			$('#divWxMenuUrl').show();$('#divWxMenuKey').hide();
		}
		else{
			$('#divWxMenuUrl').hide();$('#divWxMenuKey').show();
		}
	}).trigger('change');
})
</script>